package com.asia5b.a5mall.middleware.api

import com.asia5b.a5mall.middleware.model.member.FindPassModel
import com.asia5b.a5mall.middleware.model.member.AccessTokenModel
import com.asia5b.a5mall.middleware.utils.UUID
import io.reactivex.Observable
import okhttp3.ResponseBody
import retrofit2.http.*

/**
 * Created by zhangyuncai on 2019/12/21.
 * @Note   护照
 */
interface PassportApi {
    /**
     * @Note   登录API
     * @param  username 用户名
     * @param  password 密码
     * @param  captcha  验证码
     * @param  uuid     UUID
     */
    @GET("passport/login")
    fun login(
            @Query("username") username: String,
            @Query("password") password: String,
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<ResponseBody>

    /**
     * @Note   手机登录
     * @param  mobile  手机登录
     * @param  smsCode 短信
     * @param  uuid    uuid
     */
    @GET("passport/login/{mobile}")
    fun mobileLogin(
            @Path("mobile") mobile: String,
            @Query("sms_code") smsCode: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<ResponseBody>

    /**
     * @param account 用户名或手机号
     */
    @GET("passport/find-pwd")
    fun checkFindPwdAccount(
            @Query("account") account: String,
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<FindPassModel>

    /**
     * @Note   发送找回密码短信
     * @param  uuid 客户端唯一标示
     * @param  captcha 验证码
     */
    @POST("passport/find-pwd/send")
    fun sendMessageFindPassword(
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<ResponseBody>

    /**
     * @Note   发送找回密码短信
     * @param 手机号
     * @param  uuid 客户端唯一标示
     * @param  captcha 验证码
     */
    @GET("passport/app/find-pwd")
    fun sendMessageFindPassword2(
            @Query("account") mobile: String,
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<ResponseBody>
    /**
     * @Note   发送找回密码短信
     * @param 手机号
     * @param  uuid 客户端唯一标示
     * @param  captcha 验证码
     */
    @POST("passport/app/find-pwd/send")
    fun sendMessageFindPassword2Again(
            @Query("account") mobile: String,
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid
    ): Observable<ResponseBody>

    /**
     * @Note   发送手机注册短信
     * @param  uuid    客户端唯一标示
     * @param  captcha 验证码
     * @param  mobile  手机号
     */
    @POST("passport/register/smscode/{mobile}")
    fun sendMessageRegister(
            @Path("mobile") mobile: String,
            @Query("uuid") uuid: String = UUID.uuid,
            @Query("captcha") captcha: String,
            @Query("gr") gr: String
    ): Observable<ResponseBody>

    /**
     * @Note   发送手机登录短信
     * @param  uuid    客户端唯一标示
     * @param  captcha 验证码
     * @param  mobile  手机号
     */
    @POST("passport/login/smscode/{mobile}")
    fun sendMessageLogin(
            @Path("mobile") mobile: String,
            @Query("uuid") uuid: String = UUID.uuid,
            @Query("captcha") captcha: String,
            @Query("gr") gr: String
    ): Observable<ResponseBody>

    /**
     * @Note   发送手机注册或登录并绑定短信
     * @param  uuid    客户端唯一标示
     * @param  captcha 验证码
     * @param  mobile  手机号
     */
    @POST("passport/login/smsbindcode/{mobile}")
    fun sendMessageLoginAndBind(
            @Path("mobile") mobile: String,
            @Query("uuid") uuid: String = UUID.uuid,
            @Query("captcha") captcha: String,
            @Query("gr") gr: String
    ): Observable<ResponseBody>

    @POST("members/security/send")
    fun sendEditMessage(@Query("captcha") captcha: String, @Query("uuid") uuid: String = UUID.uuid): Observable<ResponseBody>

    @POST("members/security/bind/send/{mobile}")
    fun sendBindPassword(
            @Path("mobile") mobile: String,
            @Query("captcha") captcha: String,
            @Query("uuid") uuid: String = UUID.uuid,
            @Query("gr") gr: String
    ): Observable<ResponseBody>

    /**
     * @Note   发送手机登录短信
     * @param  smsCode 手机号验证码
     * @param  scene   场景
     * @param  mobile  手机号
     */
    @GET("passport/smscode/{mobile}")
    fun checkMobileMessage(
            @Path("mobile") mobile: String,
            @Query("scene") scene: String,
            @Query("sms_code") smsCode: String,
            @Query("gr") gr: String
    ): Observable<ResponseBody>

    /**
     * @Note   注册
     * @param  mobile 手机号
     * @param  password 密码
     */
    @POST("passport/register/wap")
    fun register(@Query("mobile") mobile: String, @Query("password") password: String, @Query("gr") gr: String): Observable<ResponseBody>

    @GET("passport/find-pwd/valid")
    fun validFindCode(@Query("sms_code") code: String, @Query("uuid") uuid: String = UUID.uuid): Observable<ResponseBody>

    /**
     * 找回密码之后的设置密码
     */
    @PUT("passport/find-pwd/update-password")
    fun findPassword(@Query("uuid") uuid: String, @Query("password") password: String): Observable<ResponseBody>


    @GET("passport/connect/app/{type}/openid")
    fun authLogin(@Path("type") type: String, @Query("openid") openid: String): Observable<ResponseBody>

    @POST("passport/sms-binder/app")
    fun authMobileBind(@Query("sms_code") smsCode: String,
                       @Query("openid") openid: String,
                       @Query("type") type: String,
                       @Query("mobile") mobile: String,
                       @Query("uuid") uuid: String = UUID.uuid): Observable<AccessTokenModel>

    @POST("passport/login-binder/app")
    fun authNormalBind(@Query("openid") openid: String,
                       @Query("type") type: String,
                       @Query("username") username: String,
                       @Query("password") password: String,
                       @Query("captcha") captcha: String,
                       @Query("uuid") uuid: String = UUID.uuid): Observable<ResponseBody>

    /*--------------------------后期添加--------------------------*/
    /**
     * @Note   发送手机验证验证码
     */
    @POST("members/security/send")
    fun sendSmsCodeByChangeMobile(): Observable<ResponseBody>

    /**
     * @Note   验证手机验证码
     */
    @GET("members/security/exchange-bind")
    fun checkSmsCodeByChangeMobile(@Query("sms_code") smsCode: String): Observable<ResponseBody>
}